﻿using GameLogic;
using TEngine;
using UnityEngine;

namespace Assets.GameScripts.Demo.FsmScene
{

    public class MovingState : FsmState<FsmDemo>
    {
        protected override void OnEnter(IFsm<FsmDemo> fsm)
        {
            Log.Debug("进入移动状态");
        }

        protected override void OnUpdate(IFsm<FsmDemo> fsm, float elapseSeconds, float realElapseSeconds)
        {

            float inputvertical = Input.GetAxis("Vertical");
            float inputHorizontal = Input.GetAxis("Horizontal");
            if (inputvertical != 0 || inputHorizontal != 0)
            {
                fsm.Owner.transform.Translate(Vector3.right * inputHorizontal * elapseSeconds*5);
                fsm.Owner.transform.Translate(Vector3.up * inputvertical * elapseSeconds*5);
            }
            else
            {
                ChangeState<IdleState>(fsm);
            }
        }

        protected override void OnLeave(IFsm<FsmDemo> fsm, bool isShutdown)
        {
        }
    }
}
